#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QModelIndex>
#include <QTimer>
#include <yaef_input.h>
#include <hyperspin.h>

namespace Ui {
class MainWindow;
}

class QListView;
class QSound;

class MainWindow : public QMainWindow
{
  Q_OBJECT
  
public:
  explicit MainWindow(QWidget *parent = 0);
  ~MainWindow();

  static void moveRow(QListView* view, int movement);

public slots:
  void switchToSystem(const QString &s, bool fav=false);
  void enableControls();

protected slots:
  void updateDate();
  void key(int k, bool sound=true);

  void leftIndexChanged(const QModelIndex&current);
  void loadArt();

  void enter();
  void back();

  void run();
  void exit();

  void keySleep();

  void hyperLaunchStarted();
  void hyperLaunchFinished();

private:
  Ui::MainWindow *_ui;
  QListView* _currentView;
  QSound* _sound;
  QTimer* _artTimer;
  QTimer* _keySleepTimer;
  QString _system;

  QPoint _oldPos;
  QSize _oldSize;

  InputThread* _inputThread;
  NativeEventBlocker* _eventBlocker;

  bool _exiting;

  void pageRow(QListView* view, int movement);
  void clearSelection(QListView* view);
  int selectedRow(QListView* view);
  void playSound(const QString& url);
};

#endif // MAINWINDOW_H
